package com.twu.biblioteca;

import java.io.PrintStream;
import java.util.List;

/**
 * Created by thoughtworker on 1/15/14.
 */
public class LibraryManager {

    private List<Book> books;

    public LibraryManager(List<Book> books) {
        this.books = books;
    }

    public void checkOutBook(String title) {
        Book book = findBook(title);
        book.checkOut();
    }

    private Book findBook(String title) {
        for (Book book : books) {
            if (title.equals(book.getTitle())) {
                return book;
            }
        }
        return null;
    }

    public void printBooks(PrintStream printStream) {
        for (Book book : books) {
            printStream.println(book.toString());
        }
        printStream.println();
    }
}
